/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.se2.meteocal.entity;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ugo
 */
@Entity   
@XmlRootElement()
@XmlAccessorType(XmlAccessType.NONE)
@NamedQueries({
    @NamedQuery(name = Calendar.findByUser, query = "SELECT c FROM Calendar c WHERE c.user = :user"),
    @NamedQuery(name = Calendar.findById, query = "SELECT c.user FROM Calendar c WHERE c.calendarId = :id")
})

public class Calendar implements Serializable {
  
    public static final String findByUser = "Calendar.findByUser";
    public static final String findById = "Calendar.findById";
    
    @XmlAttribute
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Id
    private Long calendarId;
    
    @XmlElement
    @OneToOne
    private Users user;
    
    @XmlAttribute
    private boolean isprivate;
    
    public Calendar(){
    }
    
    public Calendar(Users user) {
        this.user = user;
        isprivate= false;
    }
    
    public Calendar(Long id, Users user, Boolean bool){
        this.calendarId=id;
        this.user=user;
        this.isprivate=bool;
    }
    
    public void setId(Long id){
        this.calendarId=id;
    }
    
    public long getId(){
        return this.calendarId;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public boolean isPrivate() {
        return isprivate;
    }

    public void setisPrivate(boolean isprivate) {
        this.isprivate =isprivate;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Calendar other = (Calendar) obj;
        return Objects.equals(this.calendarId, other.calendarId);
    }
   
}

